/**
 * Created with IntelliJ IDEA.
 * User: ajhin
 * Date: 4/10/13
 * Time: 8:59 PM
 * To change this template use File | Settings | File Templates.
 */
package societyGames.codeAlong.view
{
import flash.display.DisplayObject;

import mx.core.UIComponent;

public class DisplayObjectUIComponent extends UIComponent
{
  private var _displayObject:DisplayObject;

  public function set displayObject(value:DisplayObject):void
  {
    if (_displayObject)
    {
      removeChild(_displayObject);
    }
    _displayObject = value;
    if (_displayObject)
    {
      addChild(_displayObject);
    }
    invalidateDisplayList();
  }

  public function get displayObject():DisplayObject
  {
    return this._displayObject;
  }

  override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
  {
    super.updateDisplayList(unscaledWidth, unscaledHeight);
    if (_displayObject)
    {
      _displayObject.width = unscaledWidth;
      _displayObject.height = unscaledHeight;
    }
  }
}
}
